﻿package mortal.game.view.vip
{
    import Message.DB.Tables.*;
    import Message.Game.*;
    import Message.Public.*;
    import flash.utils.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.cache.packCache.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.utils.*;

    public class VipCache extends Object
    {
        public var isCanGetWin:Boolean;
        public var wing288GetTime:Date;
        public var reChargeMoney:int;
        public var level:Number = NaN;
        private var _getRewardDic:Dictionary;
        private var _freeInfo:SVipInfo;

        public function VipCache()
        {
            this._getRewardDic = new Dictionary();
            return;
        }// end function

        public function getTVipConfigByType(param1:int) : String
        {
            var _loc_3:String = null;
            var _loc_2:* = VipConfig.instance.getVipConfigByType(param1);
            if (isNaN(this.level))
            {
                return "0";
            }
            switch(this.level)
            {
                case 0:
                {
                    _loc_3 = "0";
                    break;
                }
                case -1:
                {
                    _loc_3 = _loc_2.vipExper;
                    break;
                }
                default:
                {
                    _loc_3 = _loc_2["vip" + this.level];
                    break;
                }
            }
            if (_loc_3 == null)
            {
                _loc_3 = "";
            }
            return _loc_3;
        }// end function

        public function get freeInfo() : SVipInfo
        {
            return this._freeInfo;
        }// end function

        public function set freeInfo(param1:SVipInfo) : void
        {
            this._freeInfo = param1;
            return;
        }// end function

        public function updateGetRewardList(param1:Array) : void
        {
            var _loc_2:SVipRewardGetInfo = null;
            for each (_loc_2 in param1)
            {
                
                this._getRewardDic[_loc_2.vipLevel] = _loc_2.isGet;
            }
            return;
        }// end function

        public function get freeFlyBootTimes() : int
        {
            var _loc_2:PackPosTypeCache = null;
            var _loc_3:ItemData = null;
            var _loc_1:* = this.getLeftFreeTimesByType(EVipRecordType._EVipRecordTypePass);
            if (_loc_1 != -1)
            {
                _loc_2 = Cache.instance.pack.getFashionPackCacheByCode(EAdvanceComponentType._EAdvanceComponentTypeWing);
                if (_loc_2)
                {
                    _loc_3 = _loc_2.getItemByCode(GameConst.TConstWingShapeCardFlyCode);
                    if (_loc_3)
                    {
                        _loc_1 = -1;
                    }
                    else
                    {
                        _loc_3 = _loc_2.getItemByCode(GameConst.TConstExperWingShapeCardCode);
                        if (_loc_3 && !ItemsUtil.isPrescriOutTime(_loc_3))
                        {
                            _loc_1 = -1;
                        }
                    }
                }
            }
            return _loc_1;
        }// end function

        public function get freeRevivalTimes() : int
        {
            var _loc_1:* = this.getLeftFreeTimesByType(EVipRecordType._EVipRecordTypeRelive);
            return _loc_1;
        }// end function

        public function getLeftFreeTimesByType(param1:int) : int
        {
            if (this._freeInfo == null)
            {
                return 0;
            }
            var _loc_2:* = this.getTVipConfigByType(param1);
            var _loc_3:* = parseInt(_loc_2);
            var _loc_4:* = this._freeInfo.welfareNumDict[param1];
            if (_loc_3 == -1)
            {
                return -1;
            }
            if (_loc_3 <= _loc_4)
            {
                return 0;
            }
            return _loc_3 - _loc_4;
        }// end function

        public function getVipFreeTimesByType(param1:int) : int
        {
            var _loc_2:int = 0;
            if (this._freeInfo == null)
            {
                _loc_2 = parseInt(this.getTVipConfigByType(param1));
            }
            else
            {
                _loc_2 = this._freeInfo.welfareNumDict[param1];
            }
            return _loc_2;
        }// end function

        public function resetVipFreeTimes() : void
        {
            var _loc_1:String = null;
            if (this._freeInfo)
            {
                for (_loc_1 in this._freeInfo.welfareNumDict)
                {
                    
                    this._freeInfo.welfareNumDict[_loc_1] = 0;
                }
            }
            return;
        }// end function

        public function get getRewardDic() : Dictionary
        {
            return this._getRewardDic;
        }// end function

    }
}
